import React, { PropTypes, Component} from 'react';
import {render} from 'react-dom';


class LoadingElement extends Component {

    constructor(props) {
        super(props);

        this.state = {
            isOpen: false,
        };

        //绑定this指针
        this.hide = this.hide.bind(this);
        this.show = this.show.bind(this);
    }

    hide(){
        this.setState({"isOpen":false});
    }

    show(){
        this.setState({"isOpen":true});
    }

    render() {
        let style={
            display:this.state.isOpen?'block':'none'
        }
        return (
            <div className="loading" style={style}>
                <div className="loading-background"></div>
                <div className='loading-img'></div>
            </div>
        );
    }
}

let node=document.createElement('div');
document.body.appendChild(node);

let Loading=render(
    <LoadingElement/>,
    node
)

export default Loading;